
/*
 * FreeRTOS STC port V1.0.2
 *
 * STC32G12K128?????
 *    2? CAN, 3?Lin, USB, 32? 8051, RMB5,
 *    ???12?ADC, DMA ??(TFT??, ADC, 4???, SPI, I2C )
 *
 *  ???????????????????????????
 *  ??????????STC????STC?????????????
 *
 *  ??????????????????????????????
 *  ??????????????STC?FreeRTOS?????
 */

#include "FreeRTOS.h"
#include "task.h"
#include "System_init.h"

#include "display.h"
#include "rtc.h"
#include "ntc.h"
#include "adckey.h"
#include "uart2_3.h"
#include "MatrixKey.h"
#include "i2c_ps.h"
#include "pwmb.h"
#include "led.h"

void vSystemInit(void);

void main(void)
{
    /* ????? */
    vSystemInit();

    /* ???? */
    xTaskCreate((TaskFunction_t)vCanTransTask,
                (const char *)"CANTRANS",
                (uint16_t)configDEFAULT_STACK_SIZE,
                (void *)NULL,
                (UBaseType_t)(configDEFAULT_PRIORITIES + 5),
                (TaskHandle_t *)&CanTrans_Handler);

    xTaskCreate((TaskFunction_t)vPrintfTask,
                (const char *)"PRINTF",
                (uint16_t)configDEFAULT_STACK_SIZE,
                (void *)NULL,
                (UBaseType_t)(configDEFAULT_PRIORITIES + 1),
                (TaskHandle_t *)&Printf_Handler);

    //    xTaskCreate((TaskFunction_t )vRtcTask,
    //                (const char*    )"RTC",
    //                (uint16_t       )configDEFAULT_STACK_SIZE,
    //                (void*          )NULL,
    //                (UBaseType_t    )(configDEFAULT_PRIORITIES + 1),
    //                (TaskHandle_t*  )NULL);
    //
    //    xTaskCreate((TaskFunction_t )vAdcKeyTask,
    //                (const char*    )"ADCKEY",
    //                (uint16_t       )configDEFAULT_STACK_SIZE,
    //                (void*          )NULL,
    //                (UBaseType_t    )(configDEFAULT_PRIORITIES),
    //                (TaskHandle_t*  )NULL);
    //
    //    xTaskCreate((TaskFunction_t )vNtcTask,
    //                (const char*    )"NTC",
    //                (uint16_t       )configDEFAULT_STACK_SIZE,
    //                (void*          )NULL,
    //                (UBaseType_t    )(configDEFAULT_PRIORITIES),
    //                (TaskHandle_t*  )NULL);
    //    xTaskCreate((TaskFunction_t )vUart2_3Task,
    //                (const char*    )"UART2_3",
    //                (uint16_t       )configDEFAULT_STACK_SIZE,
    //                (void*          )1000,  //??pvParameters??????????????24????????8????????0. ???????????32????.
    //                (UBaseType_t    )(configDEFAULT_PRIORITIES),
    //                (TaskHandle_t*  )NULL);
    //
    //    xTaskCreate((TaskFunction_t )vMatrixKeyTask,
    //                (const char*    )"MatrixKey",
    //                (uint16_t       )configDEFAULT_STACK_SIZE,
    //                (void*          )NULL,
    //                (UBaseType_t    )(configDEFAULT_PRIORITIES),
    //                (TaskHandle_t*  )NULL);

    xTaskCreate((TaskFunction_t)vI2C_PsTask,
                (const char *)"I2C_PS",
                (uint16_t)configDEFAULT_STACK_SIZE,
                (void *)NULL,
                (UBaseType_t)(configDEFAULT_PRIORITIES),
                (TaskHandle_t *)NULL);

    xTaskCreate((TaskFunction_t)CanReceiveTask,
                (const char *)"CanReceive",
                (uint16_t)configDEFAULT_STACK_SIZE,
                (void *)NULL,
                (UBaseType_t)(configDEFAULT_PRIORITIES),
                (TaskHandle_t *)&CanReceive_Handler);

    /* ????????????? */
    vTaskStartScheduler();

    /* ???????????? */
    while (1)
        ;
}
